package com.kun.video.ui.window;

import cn.hutool.core.collection.CollUtil;
import com.kun.video.util.ComUtil;

/**
 * 数据上下文
 *
 * @author gzc
 * @since 2025/3/31 17:55
 **/
public class VideoToVideoButtonDataContext {
    private final VideoView videoView;
    private final VideoButtonView videoButtonView;

    public VideoToVideoButtonDataContext(VideoView videoView, VideoButtonView videoButtonView) {
        this.videoView = videoView;
        this.videoButtonView = videoButtonView;
        bindData();
    }

    public void bindData() {
        ComUtil.uiThreadRun(() -> {
            videoView.setTextArea(videoButtonView.getTextArea());
            videoButtonView.setWatermarkSelector(videoView.getKunImageViewBox());
            // 同步选择的视频文件
//            videoView.currVideoFileProperty.addListener((observable, oldValue, newValue) -> {
//                if (CollUtil.isEmpty(videoButtonView.inputVideoFileListProperty.get())) {
//                    List<KunFileWrapper> list = new ArrayList<>(1);
//                    list.add(new KunFileWrapper(newValue));
//                    videoButtonView.inputVideoFileListProperty.set(list);
//                }
//            });
//            videoButtonView.inputVideoFileListProperty.addListener((observable, oldValue, newValue) -> {
//                if (CollUtil.isNotEmpty(newValue)) {
//                    videoView.vlcj.loadMedia(newValue.get(0).getAbsolutePath());
//                }
//            });
        });
    }
}
